//
//  YHCashRecordViewController.m
//  YHApp
//
//  Created by -- on 2021/6/19.
//

#import "HACashRecordVC.h"

#import "HACashRecordSubVC.h"

#import "SGPagingView.h"

@interface HACashRecordVC ()<SGPageTitleViewDelegate,SGPageContentViewDelegate>

@property (nonatomic, strong) SGPageTitleView *pageTitleView;

@property (nonatomic, strong) SGPageContentView *pageContentView;

@end

@implementation HACashRecordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.baseTLabel.text = @"提现记录";
    
    NSMutableArray *titArr = [NSMutableArray array];
    NSMutableArray *vcArr = [NSMutableArray array];
    
    [titArr addObject:@"全部"];
    [titArr addObject:@"申请中"];
    [titArr addObject:@"申请失败"];
    [titArr addObject:@"已完成"];

    HACashRecordSubVC *vc0 = [[HACashRecordSubVC alloc]init];
    vc0.source_id = @"0";
    HACashRecordSubVC *vc1 = [[HACashRecordSubVC alloc]init];
    vc1.source_id = @"1";
    HACashRecordSubVC *vc2 = [[HACashRecordSubVC alloc]init];
    vc2.source_id = @"2";
    HACashRecordSubVC *vc3 = [[HACashRecordSubVC alloc]init];
    vc3.source_id = @"3";
    [vcArr addObject:vc0];
    [vcArr addObject:vc1];
    [vcArr addObject:vc2];
    [vcArr addObject:vc3];

    self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, app_topH+44, kUIScreen_w, 44) delegate:self titleNames:titArr titleFont:[UIFont systemFontOfSize:18]];
    [self.view addSubview:_pageTitleView];
    _pageTitleView.isTitleGradientEffect = NO;
    _pageTitleView.indicatorLengthStyle = SGIndicatorLengthStyleEqual;
    _pageTitleView.isNeedBounces = NO;
    _pageTitleView.titleColorStateNormal = [UIColor colorWithHexString:@"#666F83"];
    _pageTitleView.titleColorStateSelected = [UIColor colorWithHexString:@"#21252A"];
    _pageTitleView.indicatorColor = [UIColor colorWithHexString:@"#000000"];
    _pageTitleView.indicatorHeight = 1;
    _pageTitleView.titleTextScaling = 0;
    _pageTitleView.isOpenTitleTextZoom = YES;

    CGFloat contentViewHeight = kUIScreen_h-app_topH-64-44-5;
    self.pageContentView = [[SGPageContentView alloc] initWithFrame:CGRectMake(0, app_topH+44+44+5, kUIScreen_w, contentViewHeight) parentVC:self childVCs:vcArr];
    self.pageContentView.isScrollEnabled = YES;
    self.pageContentView.delegatePageContentView = self;
    [self.view addSubview:_pageContentView];

    [_pageContentView setPageCententViewCurrentIndex:0];
    _pageTitleView.selectedIndex = 0;

    
    // Do any additional setup after loading the view.
}

- (void)pageTitleView:(SGPageTitleView *)pageTitleView selectedIndex:(NSInteger)selectedIndex {
    [self.pageContentView setPageCententViewCurrentIndex:selectedIndex];
}

- (void)pageContentView:(SGPageContentView *)pageContentView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {
    self.pageTitleView.selectedIndex = targetIndex;
}


@end
